<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script>
		console.log("1.数组遍历");
		var arr=[12,32,54,23,78,15,3];
		for(var i=0;i<=arr.length;i++){
			console.log(arr[i]);
		}
		
		console.log("2.筛选数组元素");
		var arr1=[2,32,43,5,54,76,65];
		var newarr1=[];
		console.log("筛选之前的数组元素："+arr1);
		for(var i=0;i<arr1.length;i++){
			if(arr1[i]>=10){
				newarr1[newarr1.length]=arr1[i];
			}
		}
		console.log("筛选之后的数组元素"+newarr1);
		
		console.log("3.数组翻转");
		var arr2=[23,15,5,55,73,59,32];
		var f;
		console.log("反转之前的数组元素："+arr2);
		for (var i=0;i<=parseInt(arr2.length/2);i++){
		f=arr2[i];
		arr2[i]=arr2[arr2.length-1-i];
		arr2[arr2.length-1-i]=f;
		}
		console.log("反转之后的数组元素"+arr2);
		
		console.log("4.数组求和、求最大值");
		var arr3=[21,43,56,76,88,34,12,1];
		console.log("数组元素为："+arr3);
		var num=0;
		var max=arr3[0];
		for(var i=0;i<arr3.length;i++){
			num=num+arr3[i];
			if(arr3[i]>max){
				max=arr3[i];
			}
		}
		console.log("数组元素和为："+num);
		console.log("数组最大值为："+max);
		
		console.log("5.冒泡排序");
		var arr4=[15,32,45,65,23,84,33,24,6,96];
		console.log("排序之前的数组元素："+arr4);
		var f1;
		for(var i=arr4.length-2;i>=0;i--){
			for(var j=0;j<=i;j++){
				if(arr4[j]>arr4[j+1]){
					f1=arr4[j];
					arr4[j]=arr4[j+1];
					arr4[j+1]=f1;
				}
			}
		}
		console.log("排序后的数组元素："+arr4);
		
		console.log("6.数组去重");
		var arr5=[34,23,56,56,12,76,34,4,5];
		var newarr5=[];
		console.log("去重之前的数组元素："+arr5);
		for(var i=0;i<arr5.length;i++){
			for (var j=0;j<newarr5.length;j++){
				if(arr5[i]==newarr5[j]){
					break;
				}
			}
			if(j>=newarr5.length){
				newarr5[newarr5.length]=arr5[i]
			}
		}
		console.log("去重之后的数组元素："+newarr5);
		</script>
	</head>
	<body>
		
	</body>
</html>
